History log of /openbsd-current/sbin/ifconfig/ifconfig.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.472 18-May-2024 jsg

remove prototype with no matching function


# 1.471 23-Apr-2024 jsg

correct indentation; no functional change
ok tb@


Revision tags: OPENBSD_7_5_BASE
# 1.470 23-Nov-2023 dlg

add an endpoint command for "bridges" that use addresses as endpoints.

this can be used to add static entries on interfaces like vxlan(4).


# 1.469 23-Nov-2023 dlg

add support for specifying ports on the src address in tunnel endpoints.


# 1.468 29-Oct-2023 millert

Use clock_gettime(), not timespec_get() like other parts of ifconfig.
This makes is possible to build the base system with a C99 compiler.
OK deraadt@ mvs@


Revision tags: OPENBSD_7_4_BASE
# 1.467 09-Jun-2023 kn

Readd "-wgpsk", accidentially dropped in r1.465 adding "wgdescr"

Noticed by Bradley Latus
Diff from Jane Johansson
OK tb


# 1.466 07-Jun-2023 bluhm

Rename ifconfig tcprecvoffload to tcplro. It is shorter and
more consistent.
discussed with jan@ mvs@ chris@ claudio@ dlg@


# 1.465 01-Jun-2023 kn

Add support for wireguard peer descriptions

"wgdescr[iption] foo" to label one peer (amongst many) on a wg(4) interface,
"-wgdescr[iption]" or "wgdescr ''" to remove the label, completely analogous
to existing interface discriptions.

Idea/initial diff from Mikolaj Kucharski (OK sthen)
Tests/prodded by Hrvoje Popovski
Tweaks/manual bits from me
Feedback deraadt sthen mvs claudio
OK claudio


# 1.464 16-May-2023 jan

Use separate IFCAPs for LRO and TSO.

This diff introduces separate capabilities for TCP offloading. We split this
into LRO (large receive offloading) and TSO (TCP segmentation offloading).
LRO can be turned on/off via tcprecvoffload option of ifconfig and is not
inherited to sub interfaces.

TSO is inherited by sub interfaces to signal this hardware offloading capability
to the network stack.

With tweaks from bluhm, claudio and dlg

ok bluhm, claudio


# 1.463 12-May-2023 jan

Add interface names in front of error messages.

Suggested by Hrvoje Popovski.

ok phessler@


Revision tags: OPENBSD_7_3_BASE
# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.471 23-Apr-2024 jsg

correct indentation; no functional change
ok tb@


Revision tags: OPENBSD_7_5_BASE
# 1.470 23-Nov-2023 dlg

add an endpoint command for "bridges" that use addresses as endpoints.

this can be used to add static entries on interfaces like vxlan(4).


# 1.469 23-Nov-2023 dlg

add support for specifying ports on the src address in tunnel endpoints.


# 1.468 29-Oct-2023 millert

Use clock_gettime(), not timespec_get() like other parts of ifconfig.
This makes is possible to build the base system with a C99 compiler.
OK deraadt@ mvs@


Revision tags: OPENBSD_7_4_BASE
# 1.467 09-Jun-2023 kn

Readd "-wgpsk", accidentially dropped in r1.465 adding "wgdescr"

Noticed by Bradley Latus
Diff from Jane Johansson
OK tb


# 1.466 07-Jun-2023 bluhm

Rename ifconfig tcprecvoffload to tcplro. It is shorter and
more consistent.
discussed with jan@ mvs@ chris@ claudio@ dlg@


# 1.465 01-Jun-2023 kn

Add support for wireguard peer descriptions

"wgdescr[iption] foo" to label one peer (amongst many) on a wg(4) interface,
"-wgdescr[iption]" or "wgdescr ''" to remove the label, completely analogous
to existing interface discriptions.

Idea/initial diff from Mikolaj Kucharski (OK sthen)
Tests/prodded by Hrvoje Popovski
Tweaks/manual bits from me
Feedback deraadt sthen mvs claudio
OK claudio


# 1.464 16-May-2023 jan

Use separate IFCAPs for LRO and TSO.

This diff introduces separate capabilities for TCP offloading. We split this
into LRO (large receive offloading) and TSO (TCP segmentation offloading).
LRO can be turned on/off via tcprecvoffload option of ifconfig and is not
inherited to sub interfaces.

TSO is inherited by sub interfaces to signal this hardware offloading capability
to the network stack.

With tweaks from bluhm, claudio and dlg

ok bluhm, claudio


# 1.463 12-May-2023 jan

Add interface names in front of error messages.

Suggested by Hrvoje Popovski.

ok phessler@


Revision tags: OPENBSD_7_3_BASE
# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.470 23-Nov-2023 dlg

add an endpoint command for "bridges" that use addresses as endpoints.

this can be used to add static entries on interfaces like vxlan(4).


# 1.469 23-Nov-2023 dlg

add support for specifying ports on the src address in tunnel endpoints.


# 1.468 29-Oct-2023 millert

Use clock_gettime(), not timespec_get() like other parts of ifconfig.
This makes is possible to build the base system with a C99 compiler.
OK deraadt@ mvs@


Revision tags: OPENBSD_7_4_BASE
# 1.467 09-Jun-2023 kn

Readd "-wgpsk", accidentially dropped in r1.465 adding "wgdescr"

Noticed by Bradley Latus
Diff from Jane Johansson
OK tb


# 1.466 07-Jun-2023 bluhm

Rename ifconfig tcprecvoffload to tcplro. It is shorter and
more consistent.
discussed with jan@ mvs@ chris@ claudio@ dlg@


# 1.465 01-Jun-2023 kn

Add support for wireguard peer descriptions

"wgdescr[iption] foo" to label one peer (amongst many) on a wg(4) interface,
"-wgdescr[iption]" or "wgdescr ''" to remove the label, completely analogous
to existing interface discriptions.

Idea/initial diff from Mikolaj Kucharski (OK sthen)
Tests/prodded by Hrvoje Popovski
Tweaks/manual bits from me
Feedback deraadt sthen mvs claudio
OK claudio


# 1.464 16-May-2023 jan

Use separate IFCAPs for LRO and TSO.

This diff introduces separate capabilities for TCP offloading. We split this
into LRO (large receive offloading) and TSO (TCP segmentation offloading).
LRO can be turned on/off via tcprecvoffload option of ifconfig and is not
inherited to sub interfaces.

TSO is inherited by sub interfaces to signal this hardware offloading capability
to the network stack.

With tweaks from bluhm, claudio and dlg

ok bluhm, claudio


# 1.463 12-May-2023 jan

Add interface names in front of error messages.

Suggested by Hrvoje Popovski.

ok phessler@


Revision tags: OPENBSD_7_3_BASE
# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.468 29-Oct-2023 millert

Use clock_gettime(), not timespec_get() like other parts of ifconfig.
This makes is possible to build the base system with a C99 compiler.
OK deraadt@ mvs@


Revision tags: OPENBSD_7_4_BASE
# 1.467 09-Jun-2023 kn

Readd "-wgpsk", accidentially dropped in r1.465 adding "wgdescr"

Noticed by Bradley Latus
Diff from Jane Johansson
OK tb


# 1.466 07-Jun-2023 bluhm

Rename ifconfig tcprecvoffload to tcplro. It is shorter and
more consistent.
discussed with jan@ mvs@ chris@ claudio@ dlg@


# 1.465 01-Jun-2023 kn

Add support for wireguard peer descriptions

"wgdescr[iption] foo" to label one peer (amongst many) on a wg(4) interface,
"-wgdescr[iption]" or "wgdescr ''" to remove the label, completely analogous
to existing interface discriptions.

Idea/initial diff from Mikolaj Kucharski (OK sthen)
Tests/prodded by Hrvoje Popovski
Tweaks/manual bits from me
Feedback deraadt sthen mvs claudio
OK claudio


# 1.464 16-May-2023 jan

Use separate IFCAPs for LRO and TSO.

This diff introduces separate capabilities for TCP offloading. We split this
into LRO (large receive offloading) and TSO (TCP segmentation offloading).
LRO can be turned on/off via tcprecvoffload option of ifconfig and is not
inherited to sub interfaces.

TSO is inherited by sub interfaces to signal this hardware offloading capability
to the network stack.

With tweaks from bluhm, claudio and dlg

ok bluhm, claudio


# 1.463 12-May-2023 jan

Add interface names in front of error messages.

Suggested by Hrvoje Popovski.

ok phessler@


Revision tags: OPENBSD_7_3_BASE
# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.467 09-Jun-2023 kn

Readd "-wgpsk", accidentially dropped in r1.465 adding "wgdescr"

Noticed by Bradley Latus
Diff from Jane Johansson
OK tb


# 1.466 07-Jun-2023 bluhm

Rename ifconfig tcprecvoffload to tcplro. It is shorter and
more consistent.
discussed with jan@ mvs@ chris@ claudio@ dlg@


# 1.465 01-Jun-2023 kn

Add support for wireguard peer descriptions

"wgdescr[iption] foo" to label one peer (amongst many) on a wg(4) interface,
"-wgdescr[iption]" or "wgdescr ''" to remove the label, completely analogous
to existing interface discriptions.

Idea/initial diff from Mikolaj Kucharski (OK sthen)
Tests/prodded by Hrvoje Popovski
Tweaks/manual bits from me
Feedback deraadt sthen mvs claudio
OK claudio


# 1.464 16-May-2023 jan

Use separate IFCAPs for LRO and TSO.

This diff introduces separate capabilities for TCP offloading. We split this
into LRO (large receive offloading) and TSO (TCP segmentation offloading).
LRO can be turned on/off via tcprecvoffload option of ifconfig and is not
inherited to sub interfaces.

TSO is inherited by sub interfaces to signal this hardware offloading capability
to the network stack.

With tweaks from bluhm, claudio and dlg

ok bluhm, claudio


# 1.463 12-May-2023 jan

Add interface names in front of error messages.

Suggested by Hrvoje Popovski.

ok phessler@


Revision tags: OPENBSD_7_3_BASE
# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.462 08-Mar-2023 guenther

Delete obsolete /* ARGSUSED */ lint comments.

ok miod@ millert@


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.461 18-Jan-2023 stsp

remove redundant SIOCS80211JOIN ioctl call in ifconfig delifjoinlist()
Found by Mathias Koehler, thanks!


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.460 18-Dec-2022 kn

Unify RSSI check

Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify; "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.459 26-Nov-2022 jmc

- in SYNOPSIS, redo the formatting for "address" and "dest address" to avoid
an ugly line split on narrower terminals
- in usage(), match the output


# 1.458 25-Nov-2022 deraadt

ifconfig -M <mac> finds the address on an interface and prints it.
cloned (virtual) interfaces are skipped, and if the MAC is on more
than 1 interface, no answer either. The mac must be in same format
as the ifconfig lladdr output (complete lowercase with :)
idea from florian, ok afresh1


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.457 26-Oct-2022 kn

Limit wireguard peers listing to -A or wg-interface

ifconfig(8) output can get too long when always printing `wgpeers' for all
wg(4) interfaces, so omit it output is requested and/or output is limited
to the interface group "wg" or a specific interface "wgX".

No install media size change as wireguard code is under #ifndef SMALL.

Diff from Mikolaj Kucharski <mikolaj AT kucharski DOT name>
makes Hrvoje Popovski happy
manual bits from jmc
OK sthen


Revision tags: OPENBSD_7_2_BASE
# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.456 08-Jul-2022 jsg

remove unused variables


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.455 27-Jun-2022 jan

Introduce Large Receive Offloading of TCP segment offloading for ix(4). It is
disabled by default. Also add a tso option to ifconfig(8) to enable and
disable this feature.

ok deraadt


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.454 07-Apr-2022 naddy

constify ifmedia descriptions; ok deraadt@ miod@


Revision tags: OPENBSD_7_1_BASE
# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.453 07-Mar-2022 stsp

rename net80211 ioctl struct ieee80211_channel to struct ieee80211_chaninfo

ioctls should use dedicated names for their structs, but SIOCG80211ALLCHANS
duplicated struct ieee80211_channel. We cannot make changes to the kernel's
version of ieee80211_channel while an ioctl is squatting on the struct name.

Helpful guidance from deraadt@
Tested in a ports bulk build by sthen@, and tested by Mikhail.

ok sthen@


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.452 22-Feb-2022 dlg

don't hide the mtu on "bridge" interfaces.

interfaces like vxlan and nvgre have bridges inside them and respond
to bridge ioctls, but they are still interfaces that handle l3
traffic so the mtu means something on them. if we don't want bridge
to show an mtu, that can be done by bridge(4) instead of having
ifconfig make assumptions like this.

noticed by jason tubnor
ok deraadt@ claudio@


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.451 23-Nov-2021 kn

Use system uptime not UTC time to calculate PPPoE session duration

Systems without RTC are likely to boot with wrong time, but pppoe(4) used
microtime(9) anyway to remember when a new session began.

(In)adequately, ifconfig(8) used gettimeofday(2) and calculated the
difference between two absoloute dates to infer the PPPoE session duration.

This goes off the rails if the wall clock jumps in between, e.g. due to NTP
kicking in.

Use getmicrouptime(9) and clock_gettime(2)/CLOCK_BOOTTIME instead to rely
on the monotonically increasing system uptime instead to fix this.

Reported and tested by Peter J. Philipp <pjp AT delphinusdns DOT org> on
some octeon box without RTC.
I've seen this on a Edgerouter 4 as well (2m uptime, 19d session).

OK claudio


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.450 17-Nov-2021 bket

Display DNS information from sppp(4) in ifconfig(8)

Behaviour is similar to that of umb(4).

OK kn@


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.449 11-Nov-2021 claudio

Remove switch(4) specific bits from ifconfig.
OK deraadt@ patrick@


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.448 03-Nov-2021 kn

Zap swapips remnants

There since 1998, probably dead long before.

"I am sure swabips died before you were born." deraadt


# 1.447 02-Nov-2021 kn

fix previous


# 1.446 02-Nov-2021 kn

Return non-zero on failed "nwkey" command

Fail early and exit non-zero immediately instead of indicating success and
possibly carrying the next ifconfig command.

Found at install when wifi interfaces are reset with "-nwid -nwkey -wpa":

Which network interface do you wish to configure? (or 'done') [bse0] bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]

bwfm(4) currently does not support WEP.

OK stsp


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.445 06-Oct-2021 florian

Remove autoconfprivacy deprecation warning.
OK deraadt


Revision tags: OPENBSD_7_0_BASE
# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.444 12-Jul-2021 beck

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.443 04-Jul-2021 sthen

store provider ID in umb(4), and display it in ifconfig. OK stsp deraadt

Previously only the provider's display name was used. The text used depends
on how the SIM is configured and not just on the network in use (for example,
an MVNO SIM on another network will often display the MVNO's name rather
than that of the underlying network).

I have a SIM that roams to any network in my country - whichever network
it roams onto, the display name is the same, so you can't tell which
network you're really using. By printing the provider ID (in GSM-land this
is MCC+MNC) it's easy to lookup and check this.

As the provider was printed on the ifconfig line also showing subscriber-id
and ICCID it was already a bit long, and adding the provider-id there is
a bit too much, so move it to the output line showing APN, now looking like

: subscriber-id 2400xxxxxxxxxxx ICC-id 8946203xxxxxxxxxxxxx
: device EM7455 IMEI 01458xxxxxxxxxx firmware SWI9X30C_02.24.0
: APN key provider Tele2 IoT provider-id 23420


Revision tags: OPENBSD_6_9_BASE
# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.442 20-Mar-2021 florian

RFC 8981 allows the configuration of only temporary IPv6 addresses.
Keep "temporary" the default when setting inet6 autoconf but make it
possible to disable the "autoconf" flag but keep "temporary" enabled.
The normal usecase to only have temporary autoconf addresses would be
"inet6 temporary" in hostname.if
OK kn


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.441 16-Mar-2021 kn

Move setifrtlabel() and *keepalive() prototypes out of SMALL

Those commands are not supported under SMALL; unless I overlooked others,
this should be the last bit to declare all prototypes correctly wrt. SMALL
(the overall unsorted order of both prototypes and commands makes this hard
to spot).

No object change, with and without SMALL.


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.440 13-Mar-2021 kn

Remove "deletetunnel" (deprecated with 6.4)

OK deraadt


# 1.439 13-Mar-2021 kn

Move all rdomain bits under SMALL

"[-]rdomain" commands are ignored under SMALL but their prototypes,
the global and therefore dead print logic are still in.

OK deraadt


# 1.438 13-Mar-2021 kn

Move MPLS related function prototypes under SMALL

OK deraadt


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.437 12-Mar-2021 florian

Add deprecation warning for autoconfprivacy.
While here check address family for 'temporary' option, only inet6 is
allowed.
OK kn


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.436 11-Mar-2021 florian

When RFC 8981 obsoleted RFC 4941 the terminology changed from
"privacy extensions" to "temporary address extensions"

Change ifconfig(8) to output temporary after temporary addresses and
add "temporary" option which is an alias for autoconfprivacy for now.

Also make AUTOCONF6TEMP a positiv flag that is set by default.
Previously the negative flag "INET6_NOPRIVACY" was set when privacy
addresses were disabled. This makes the flags output less ugly and
will allow us to disable autoconf addresses while having temporary
addresses enabled in the future.

More work is needed in slaacd.

input benno, jmc, deraadt
previous verison OK benno
OK jmc, kn


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.435 04-Mar-2021 jsg

remove extra argument to printf


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.434 20-Feb-2021 dlg

add support for handling the interface monitor flag

ok benno@


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.433 10-Feb-2021 bluhm

Use the same check in kernel and ifconfig for group names. ifconfig
delete group does not need name sanitation. The kernel will just
report that it does not exist.
OK deraadt@ gnezdo@ anton@ mvs@ claudio@


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.432 16-Jan-2021 claudio

Only recover the scope_id if it was not set. This way this code works
both with and without embedded scope.
OK bluhm@ florian@


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.431 30-Dec-2020 benno

getifaddrs() can return entries where ifa_addr is NULL. Check for this
before accessing anything in ifa_addr.
ok claudio@


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.430 06-Nov-2020 kn

Keep track of allowed ips pointer correctly

Someone reported wg(4) not working on macppc; fix ifconfig(8)'s "wgaip" to
interate over data structures in the same way as the kernel does.

Analysis and fiff from Jason A. Donenfeld
Tested on macppc, sparc64 and amd64 by me


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.429 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.

OK kn@, input from claudio@


# 1.428 07-Oct-2020 denis

Reverse previous, needs discussion.


# 1.427 07-Oct-2020 denis

Fix display of P2P link to be consistent over all AF.


Revision tags: OPENBSD_6_8_BASE
# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.426 15-Sep-2020 claudio

umb(4) shows the speed of the LTE connection but misses the b in Mbps.
OK kettenis@


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.425 05-Aug-2020 kn

Merge switch_status() into bridge_status()

This is to reduce duplicate code and prepare for bridge_status() to cover
all bridge like interfaces: bridge(4), switch(4) and tpmr(4).

OK dlg


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.424 03-Jul-2020 florian

Rename IN6_IFF_PRIVACY to IN6_IFF_TEMPORARY.
This is the name the other BSDs use for this, there is no reason to
be different, the IPv6 RFCs call these addresses temporary, and some
software in ports wants to use this as well.
Most recently pointed out for firefox by landry.
OK claudio, sthen


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.423 22-Jun-2020 dlg

use (undocumented) base64 code in libc instead of libcrypto.

naddy gave me a pointer in the right direction
ok millert@ deraadt@
looks good to matt dunwoodie


# 1.422 21-Jun-2020 dlg

teach ifconfig about wireguard.

note that this links ifconfig with libcrypto to get at base64
encoding and decoding routines. im looking at an alternative way
to do that, so hopefully this is temporary.

secondly, note that all the wireguard stuff is under ifndef SMALL,
so the special build of ifconfig for install media does include
wireguard support, and also does not need libcrypto.

from Matt Dunwoodie and Jason A. Donenfeld

ok deraadt@


Revision tags: OPENBSD_6_7_BASE
# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.421 27-Feb-2020 stsp

Do not set A_JOIN unconditionally. Otherwise join "" takes effect even
though that is not what the user intended, e.g. if an invalid hex SSID
was given on the command line.

ok sthen@


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.420 24-Feb-2020 stsp

fix column alignment of 'ifconfig joinlist'; padding had an extra " "


# 1.419 24-Feb-2020 stsp

Don't needlessly cap SSID width in 'ifconfig joinlist' (matters with hex SSIDs).

ok kevlo@


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.418 18-Feb-2020 gerhard

Add IPv6 support to umb(4).

ok job@ bluhm@ claudio@

job@ tested with 'telnet -6 towel.blinkenlights.nl' on Fibocom L831-EAU on
IIJ MIO's network (Japan), with 'inet6 autoconf' in /etc/hostname.umb0.


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.417 27-Dec-2019 stsp

Fix ifconfig WPA key installation with max allowed length SSIDs.
ok claudio phessler deraadt sthen


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.416 30-Nov-2019 bluhm

ifconfig(8) did silently ignore the netmask parameter for inet6 and
interpreted only prefixlen. Also accept netmask for IPv6. This
is consistent to our man page and the route(8) command.
OK benno@


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.415 27-Nov-2019 deraadt

use _PATH_ names for unveil if possible


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.414 24-Oct-2019 bluhm

Fix ifconfig(8) compiler warnings regarding variable "name" reuse.
Call the global variable with the name of the interface "ifname".
Do not pass it around, just use it globally. Do not use "ifname"
for anything else.
OK deraadt@


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.413 17-Oct-2019 bluhm

Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically
this renames brconfig.h to ifconfig.h and also uses it for sff.c.
Fix missing prototypes. Global variable name s is bad as it shadows
local variables. Call it sock and use it everywhere.
OK deraadt@


Revision tags: OPENBSD_6_6_BASE
# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.412 02-Sep-2019 stsp

Make net80211 expose reasons for association failures to userland and have
ifconfig display them in 'scan' output and on the ieee80211 status line if
the failure is applicable to an already selected AP (e.g. wrong WPA key).

This will hopefully reduce the amount of help requests for what often
turn out to be trivial misconfiguration issues that were previously
hard to diagnose without debug mode.

ifconfig must be recompiled with the new ieee80211_ioctl.h to stay in
sync with the kernel. A full 'make build' will do the right thing!

Very helpful input by mpi@ and deraadt@


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.411 30-Aug-2019 deraadt

whitespace, found while pondering improvements to sffdump


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.410 26-Aug-2019 claudio

Adjust umb DNS printing code since the type of those addresses changed.
OK gerhard@


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.409 08-Aug-2019 mestre

added /* no filesystem visibility */ above unveil("/", "") since "" is too easy
to misread.

as per suggestion by and OK deraadt@


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.408 25-Jul-2019 krw

AF_INET comes before AF_INET6. Shorten line to <80 chars.

pointed out by claudio@


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.407 25-Jul-2019 krw

Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Let
ifconfig set/unset it.

ok deraadt@ kmos@


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.406 25-Jul-2019 dlg

make a half-hearted attempt to shrink trunkport info a bit

it's hard to balance being understandable without a legend or a big
manpage, and not using a lot of space.

ok deraadt@


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.405 24-Jul-2019 dlg

print out lacp actor and parter info

this is useful for diagnosing mismatches between configurations on
sets of ports (and debugging aggr(4)).


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.404 03-Jul-2019 deraadt

snprintf/vsnprintf return < 0 on error, rather than -1.


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.403 28-Jun-2019 deraadt

When system calls indicate an error they return -1, not some arbitrary
value < 0. errno is only updated in this case. Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.402 10-May-2019 guenther

Delete superfluous #includes of <ifaddrs.h>, <net/if_dl.h>, and <net/if_enc.h>

ok krw@, jsg@


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.401 19-Apr-2019 dlg

add support for getting and setting rxprio

this complements txprio and should finish support for RFC 2983

ok claudio@


# 1.400 15-Apr-2019 kn

Remove old vlan and [-]vlandev code

These were deprecated with 6.3, but instead of removing them all together,
keep [-]vlan and [-]vlandev as aliases for [-]vnetid and [-]parent.

Alias idea from sthen
OK dlg sthen benno


Revision tags: OPENBSD_6_5_BASE
# 1.399 11-Apr-2019 sthen

print transceiver information inline with standard interface details
(like media/joinlist do) rather than totally separate; this also allows
"ifconfig -a sff" or "ifconfig ix sff".

tweak display format to make it look closer to the standard lines.

ok deraadt


# 1.398 10-Apr-2019 dlg

add support for fetching and parsing SFF module info and diags

this is very basic, and will get cut up a lot by sthen@ soon, but
it was enough to get us started with. at the moment it shows the
type of module, some vendor and products strings, and detects if
the device supports diag and then shows it. qsfp info is structured
very differently, but i'll let sfp support settle before trying to
make it look the same.

so far only ix(4) and some ixl(4) with up to date firmware implement
the backend ioctl for this. no em(4) yet :(

suggestions from mikeb@
ok deraadt@ sthen@

this was started because of a question from rachel roch


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.397 11-Mar-2019 dlg

remove an extra ; on a line

no functional change


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.396 26-Feb-2019 dlg

get rid of the mpw goop

this reduces the output that mpw interfaces generate from 3 lines
to the one generic mpls and pwe3 line.

mpw can be configured with the individual ioctls, and gains the
ability to do flow aware transport.


# 1.395 26-Feb-2019 dlg

implement support for pwe3 ioctls

this allows individual configuration of the use of control words,
flow aware tranport labels, and the local and remote label plus
neighbor individually.

discussed with claudio@ at a2k19
ok mpi@


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.394 20-Feb-2019 jca

Tweak previous, use the same wording everywhere

ok deraadt@


# 1.393 20-Feb-2019 deraadt

avoid abbreviation "AF" when "address family" fits on the line; noted by Alfred Morgan


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.392 19-Feb-2019 stsp

Make ifconfig(8) display whether bwfm(4) firmware is using 802.11ac.
ok patrick@ mpi@


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.391 23-Jan-2019 krw

Nuke unused variable.

ok phessler@


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.390 19-Jan-2019 phessler

properly error out instead of only printing a warning when some join commands
failed

OK deraadt@


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.389 18-Jan-2019 phessler

let users automatically use join to connect to any open wifi network.
if a known network is visible, always prefer that instead.

requested by many, OK stsp@


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.388 17-Jan-2019 phessler

do not allow users to specify "join" or "nwid" twice on the same ifconfig call


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.387 29-Nov-2018 dlg

handle tunnel ecn configuration and reporting.

tested with normal and special ifconfig builds.

ok claudio@


# 1.386 25-Nov-2018 phessler

print more details about the join'd networks we have saved when a user runs
ifconfig if joinlist

OK stsp@


# 1.385 25-Nov-2018 phessler

merge the wpa related settings, instead of overriding them
this fixes setting wpaprotos (e.g. enabling wpa1)

OK stsp@


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.384 20-Nov-2018 phessler

when printing essids return the number of chars we printed, like printf

OK stsp@


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.383 14-Nov-2018 kn

Warn on deprecated 'vlan' and 'vlandev' option usage

These were superseeded by 'vnetid' and 'parent' in june 2017 and will be
removed in the future.

"Looks right" deraadt, OK benno


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.382 12-Nov-2018 dlg

add support for txprio settings on interfaces

display of the currently configured txprio setting is added to the
encap line, since it's configuring something that affects the
population of an encapsulation header.

it also adds a txprio argument to ifconfig so the setting can be
changed to "payload", "packet", or a number between 0 and 7.

ok claudio@


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.381 10-Nov-2018 kn

Fix vnetid range

0 and 4095 are reserved IDs as per 802.1Q and vlan(4), setting them will
fail.

OK denis


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.380 15-Oct-2018 florian

The struct members addr and dstaddr in struct if_laddrreq are struct
sockaddr_storage which is guarantee to be large enough, no need to
check ai_addrlen. We can also trust the resolver to give us a
sockaddr_in6 sized object if we ask for AF_INET6
OK kn, deraadt


Revision tags: OPENBSD_6_4_BASE
# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.379 30-Sep-2018 denis

deny non-contiguous netmask

OK job@


# 1.378 09-Sep-2018 phessler

convert the things we save in 'join' into a single ioctl. mixing related
settings over multiple calls was risky and racy. Pass essid, wpa, and wep
paramaters in a single ioctl and process it atomically.

no change for 'nwid' users

OK stsp@ benno@


# 1.377 08-Sep-2018 phessler

Enforce that "join" and "nwid" may not be used at the same time.

OK stsp@


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.376 15-Aug-2018 florian

Restore ability to use hostnames to configure ip addresses.
Unveil /etc/{resolv.conf,hosts,services} which keeps it in sync with
the kernel bypass for pledge("dns").
OK deraadt
pointed out by & OK stsp


# 1.375 12-Aug-2018 ccardenas

Add administrative options to LACP trunk implementation.

The trunk driver now has a new ioctl (SIOCxTRUNKOPTS), which for now only
has options for LACP:
* Mode - Active or Passive (default Active)
* Timeout - Fast or Slow (default Slow)
* System Priority - 1(high) to 65535(low) (default 32768/0x8000)
* Port Priority - 1(high) to 65535(low) (default 32768/0x8000)
* IFQ Priority - 0 to NUM_QUEUES (default 6)

At the moment, ifconfig only has options for lacpmode and lacptimeout
plumbed as those are the immediate need.

The approach taken for the options was to make them on a "trunk" vs a
"port" as what's typically seen on various NOSes (JunOS, NXOS, etc...)
as it's uncommon for a host to have one link "Passive" and the other
"Active" in a given trunk.

Just like on a NOS, when applying lacpmode or lacptimeout, the settings
are immediately applied to all existing ports in the trunk and to all
future ports brought into the trunk.

Tested by many on a plethora of NIC drivers and switches.

Ok remi@


# 1.374 12-Aug-2018 stsp

Make ifconfig's -joinlist command work as advertised.
ok deraadt phessler


# 1.373 11-Aug-2018 benno

Fix problems ofthe ifconfig argument parser with "ifconfig <if> join".
Due to the way the parsing works, you cannot have an option that
accepts strings as argument or no argument, without side effects: for
example "join <nwid>" could only join networks that did not have a
nwid identical to another ifconfig option, i.e. "join mtu" or "join
join" would not work.

Solve this by making join always require an nwid. Listing all the
configured nwids for auto-join is moved to the new option "joinlist".
Removing _all_ auto-join configuration is moved to "-joinlist".

deraadt@ likes it and ok phessler@ stsp@


# 1.372 08-Aug-2018 florian

ifconfig cannot be pledged because of its overwhelming amount of
used ioctls. Furthermore due to the way the command line parser is
written it is difficult to apply the traditional first initialize then
pledge pattern.

unveil(2) gives us a different approach:
By veiling everything with unveil("/", "") and then locking down
unveil with unveil(NULL, NULL) we remove all filesystem access from
ifconfig kind of like giving a regular user a chroot without any
files.

OK deraadt


# 1.371 08-Aug-2018 deraadt

tabs are ok at start of line, but internally space seperation is the norm


# 1.370 06-Aug-2018 benno

make ifconfig <if> join display the list of networks configured for
auto-join
with feedback from florian and stsp
ok florian@ phessler@ (on previous versions of the diff) stsp@


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.369 13-Jul-2018 krw

Unused variables.

ok henning@ phessler@


# 1.368 11-Jul-2018 phessler

Introduce 'auto-join' to the wifi 802.11 stack.

This allows a system to remember which ESSIDs it wants to connect to, any
relevant security configuration, and switch to it when the network we are
currently connected to is no longer available.

Works when connecting and switching between WPA2/WPA1/WEP/clear encryptions.

example hostname.if:
join home wpakey password
join work wpakey mekmitasdigoat
join open-lounge
join cafe wpakey cafe2018
join "wepnetwork" nwkey "12345"
dhcp
inet6 autoconf
up

OK stsp@ reyk@
and enthusiasm from every hackroom I've been in for the last 3 years


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.367 28-May-2018 kn

Remove unused <sys/param.h>

OK sthen mpi


# 1.366 12-May-2018 ccardenas

Make LACP_STATE_BITS accessible to userland

Update ifconfig to display LACP State (Actor and Partner) on
each trunk port

Ok benno@, phessler@, and tb@


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.365 26-Apr-2018 pirofti

net80211: stub SIOCS80211SCAN, make ifconfig scan instant.

The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.

The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.

In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.

The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...

Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.

Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).

Tested by mpi@, landry@, florian@, thanks!
OK mpi@.


# 1.364 26-Apr-2018 schwarze

Do not try getnetbyname(3) if gethostbyname(3) returns no result.
This is part of the project to delete /etc/networks support.
OK deraadt@


# 1.363 26-Apr-2018 akoshibe

Add a '-tunneldomain' ifconfig(8) option as shorthand for 'tunneldomain 0'
to be consistent with the '-rdomain' option.

Suggested by dlg
OK benno, jca, kn, phessler, jmc


Revision tags: OPENBSD_6_3_BASE
# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.362 27-Feb-2018 dlg

handle "tunnels" without a destination address

this is used for mgre, which has a local address but dynamically
addresses other endpoints based on routing information.

"tunneladdr" takes a single address (where "tunnel" takes two) and
sets the destination address in the ioctl to an AF_UNSPEC destination.

tunnel status is changed so it recognises this and only outputs the
local address if the destination is AF_UNSPEC. the tunnel status
is also changed so it can tell the difference between tunnels being
unsupported on the interface (ie, ENOTTY comes back) or if there's
just no address configured yet (EADDRNOTAVAIL), which allows the
other tunnel params like ttl and df to be shown.

tested with and without -DSMALL


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.361 23-Feb-2018 akoshibe

Add unsetrdomain() and option -rdomain to return an interface to routing
domain 0.

OK phessler, henning, deraadt, stsp, benno


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.360 20-Feb-2018 tb

Move getvnetflowid() out of #ifndef SMALL to unbreak 'make release'.

Diff from jsg, ok millert, benno


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.359 20-Feb-2018 dlg

add support for toggling partitioning a vnetid into a netid and flowid

"vnetflowid" enables it on an interface, and "-vnetflowid" disables it.
a vnetid will be suffixed with + on the encap line if it an interface
reports that it is enabled.


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.358 19-Feb-2018 dlg

add support for setting and displaying whether a tunnel allows fragmentation

ifconfig will output "nodf" or "df" on tunnel interfaces that support
the ioctl., and accepts "tunneldf" and "-tunneldf" as options to
try and configure it.


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.357 10-Feb-2018 florian

ifconfig can be used to to set interface flag to not do RFC 7217.

OK naddy, sthen
man page bits input & OK jmc


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.356 08-Feb-2018 dlg

when using tunnelttl, let -1 mean "copy the ttl from the inner traffic".

tunnelttl now accepts "copy" as an argument, and prints "copy" when
it sees -1.

ok claudio@


# 1.355 08-Feb-2018 mpi

Add a new '-protected' option for bridge members.

Bridge members that are part of the same protected domain, refered by
a number between 1 and 31, cannot talk to each others. This is useful
to isolate VMs or untrusted networks at layer 2.

Members can be part of multiple protected domain making it possible to
create complex protected setups.

ok ccardenas@, claudio@, dlg@, henning@


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.354 02-Feb-2018 stsp

Make 'ifconfig if0 wpaakms 802.1x' implicitly enable WPA.
Requring WPA to be enabled separately via 'ifconfig if0 wpa' was confusing.
ok mlarkin phessler mpi


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.353 16-Jan-2018 mpi

Recycle IFF_NOTRAILERS into IFF_STATICARP and document ownerhsip
of IFF* flags.

inputs from jmc@, ok bluhm@, visa@


# 1.352 09-Jan-2018 mpi

Stop printing <not displayed> for wireless keys we know the kernel no
longer export them to userland.

ok stsp@, deraadt@, jca@


# 1.351 17-Nov-2017 benno

replace the deletetunnel option with -tunnel
ok bluhm@


# 1.350 05-Nov-2017 benno

ifconfig <if> giftunnel was deprecated in 2001, it's never too late to
remove it
ok phessler@ beck@


# 1.349 30-Oct-2017 mpi

Exit printing an error message if SIOCSIFMEDIA fails.

from Jesper Wallin.


Revision tags: OPENBSD_6_2_BASE
# 1.348 29-Aug-2017 deraadt

quarterly rescan of the tree: remove unneccessary sys/param.h, and
annotate the ones which are needed.


# 1.347 29-Aug-2017 stsp

Don't use isset() from sys/param.h in ifconfig. Requested by deraadt


# 1.346 01-Aug-2017 benno

use AI_NUMERICHOST for getaddrinfo(), we can only configure ip
adresses on pflow(4) interfaces, so don't try to resolve hostnames.
Report and fix from pjp -AT- centroid.eu
ok florian@


# 1.345 25-Jun-2017 stsp

Make ifconfig(8) default to prefixlen 128 when setting an IPv6 destination
address on a point-to-point interface. Makes it easier to configure IPv6 on
interfaces such as gif(4). Specifying 'prefixlen 128' is no longer required.
This is consistent with IPv4 where a netmask is not required either.
ok mpi@ bluhm@ benno@


# 1.344 08-Jun-2017 tedu

remove the timeslot code, it was only for now deleted T1 devices.
ok sthen


# 1.343 06-Jun-2017 dlg

make vnetid and parent commands available in SMALL ifconfigs.

the code behind the commands has been built on SMALL forever, this just
moves it available in the cmd table. the binary doesnt change size.


# 1.342 05-Jun-2017 dlg

remove vlan(4) specific output handling

vlan(4) now understands the generic vnetid and ifparent ioctls, so
this is redundant.

ok henning@


# 1.341 31-May-2017 dlg

fold the vnetid and parent lines into a single encap line.

this is a modest attempt to shorten the ifconfig output. encap wont
show up if neither vnetid or parent are supplied by an interface.

whitespace tweaks from benno@
output tweaks from reyk@
ok deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE
# 1.340 21-Mar-2017 stsp

Replace a magic number with the corresponding macro from ieee80211_ioctl.h.
No functional change.
ok deraadt@ tb@


# 1.339 12-Mar-2017 stsp

Make ifconfig scan display both wpa1 and wpa2 if both are supported.
ok henning@ phessler@


# 1.338 11-Mar-2017 stsp

Make 'ifconfig scan' display AP encryption correctly if WEP is configured
on the local wifi interface. ifconfig was mistakenly showing the common
supported subset of client and AP, rather than showing the AP's capabilities.
Exposes WPA protocol capabilities in struct ieee80211_nodereq, which means
ifconfig must be recompiled to run on a new kernel.
ok deraadt@ mpi@


# 1.337 21-Jan-2017 krw

Nuke whitespace foolish enough to expose itself during the great
"warning:" rectification.


# 1.336 25-Dec-2016 krw

gcc says "if you define labels and don't use them, I will whine."

ok tom@


# 1.335 20-Dec-2016 stsp

Make 'ifconfig if0 wpa' and 'ifconfig if0 -wpa' reset WPA params (does not
include the wpakey) to their defaults.
And make 'ifconfig if0 wpaprotos' reset WPA crypto parameters to settings
which are appropriate for the specified WPA protocol version.


# 1.334 13-Dec-2016 dlg

make setting and getting tunnel addresses wrt to ipv6 scope handling.

setting a tunnel addresses uses a sockaddr_in6 from getaddrinfo, which
sets sin6_scope_id for scoped addresses. this is nice and portable.

reading a tunnel address assumed the scope was embedded in link local
addresses in sin6_addr, and unpacked the scope back into sin6_scope_id.
this is inconsistent with the code that sets tunnel addresses.

this fixes the read path so it assumes the kernel sets sin6_scope_id
like it it assumes the kernel will read on the set side. noone likes
the kame hack of embedding the scope id in the addreses.

ok mpi@


# 1.333 10-Nov-2016 gerhard

The simple UTF-16 decode routine stopped too early due to wrong calculation
of the output buffer size. Thus elements like subscriber-id, ICC-id, IMEI
were shown truncated.

Some modules report a phone number that already has the '+' prefix.
Don't add another one when printing it.

Patch from Bryan Vyhmeister
ok otto


# 1.332 08-Nov-2016 mestre

- Declare usage() as __dead void (remaining prototypes are not declared as
static, so keep it that way for consistency)
- s/usage(1)/usage() and inside call exit(1) explicitly since all usage() calls
always use that value (also update comment to reflect this change)
- Remove main() prototype
- s/exit/return in main() to enable SSP

Feedback from jca@ and tb@ and OK from both (with their remarks in)


# 1.331 17-Oct-2016 rzalamena

Use strtoull() to read the datapath id and expect "datapath" instead of
"datapathid" as stated by the man page.

ok reyk@


# 1.330 03-Sep-2016 reyk

Add support for a multipoint-to-multipoint mode in vxlan(4). In this
mode, vxlan(4) must be configured to accept any virtual network
identifier with "vnetid any" and added to a bridge(4) or switch(4).
This way the driver will dynamically learn the tunnel endpoints and
their vnetids for the responses and can be used to dynamically bridge
between VXLANs. It is also being used in combination with switch(4)
and the OpenFlow tunnel classifiers.

With input from yasuoka@ goda@
OK deraadt@ dlg@


# 1.329 02-Sep-2016 goda

Add switch(4) support to ifconfig

ok deraadt@ yasuoka@ reyk@ henning@


# 1.328 31-Aug-2016 stsp

Rename ifconfig's setinstance() function to setrdomain(). Less confusing.
ok claudio@ jca@


# 1.327 19-Aug-2016 jsg

correct a rate test introduced in rev 1.326
ok stsp@


# 1.326 15-Aug-2016 stsp

When running 'ifconfig scan' in hostap mode display the current Tx rate our
AP is using to send frames to an associated node. This used to always display
the node's highest supported Rx rate, which isn't all that interesting.
ok mpi@


# 1.325 03-Aug-2016 vgross

Fix typo, spotted by Holger Mikolon <holger@mikolon.com>


Revision tags: OPENBSD_6_0_BASE
# 1.324 15-Jun-2016 gerhard

Add umb(4) - a driver for the Mobile Broadband Interface Model (MBIM)

The umb(4) driver provides support for USB MBIM devices.
Those devices establish connections via celluar networks such as
GPRS, UMTS, and LTE.

ok mpi@ sthen@
additional feedback from deraadt@ jmc@ stsp@ kettenis@


# 1.323 10-Jun-2016 vgross

Add the "llprio" field to struct ifnet, and the corresponding keyword
to ifconfig.

"llprio" allows one to set the priority of packets that do not go through
pf(4), as the case is for arp(4) or bpf(4).

ok sthen@ mikeb@


# 1.322 03-May-2016 jca

Remove INET6 #ifdefs

ifconfig.c doesn't build without -DINET6, and those #ifdefs clutter the
code. ok bluhm@ henning@


# 1.321 28-Apr-2016 stsp

Show 11n HT rate in ifconfig scan output. Needs a new kernel.
ok mpi@


# 1.320 18-Apr-2016 mpi

Print interface index after priority.

Suggestion from claudio@, ok benno@, sthen@


# 1.319 06-Apr-2016 dlg

move the parent and vnetid stuff around so it builds on ramdisks too.

ramdisk breakage found by jsg@
ok jsg@


# 1.318 06-Apr-2016 dlg

move getting the vnetid out next to getting the ifparent

its now separate to getting the tunnel address.

ok mpi@


# 1.317 02-Mar-2016 deraadt

repair for ramdisk builds


# 1.316 02-Mar-2016 dlg

provide generic ioctls for managing an interfaces parent

in the future this will subsume the individual vlandev, carpdev,
pppoedev, foodev options for things like vlan, carp, pppoe, etc.

inspired by vnetid

ok mpi@ jmatthew@


Revision tags: OPENBSD_5_9_BASE
# 1.315 13-Jan-2016 stsp

Make 'ifconfig $if mode' a valid subcommand that works independently of
the 'media' subcommand. Allow clearing the mode with 'ifconfig $if -mode'.

This makes commands such as 'ifconfig iwn0 mode 11a' work without having
to type all of 'ifconfig iwn0 media autoselect mode 11a'.

ok sthen@ deraadt@ jmc@


# 1.314 06-Jan-2016 tedu

correct format string. ok deraadt stsp


# 1.313 03-Jan-2016 mpi

Remove obsolete and undocumented "-carpdev" option, from Fabian Raetz.

ok benno@, claudio@


# 1.312 01-Jan-2016 jung

rmeove unused noprint variable

from Fabian Raetz via tech@

ok krw


# 1.311 10-Dec-2015 mmcc

Remove NULL-checks before free(). ok tb@


# 1.310 09-Dec-2015 mpi

Revert SIOCDIFADDR_IN6 fix.

It's not possible to fix this issue in ifconfig(8) because in_control()
and in6_control() have a subtle semantic difference which result in
breaking alias for IPv4.

in_control() always select the first address on the list of an interface
whereas in6_control() doesn't. That's why ifconfig(8) passes an empty
"struct in_aliasreq" and that fails in netinet6.

Breakage reported by deraadt@


# 1.309 06-Dec-2015 tedu

remove trailers option that was already obsolete when this code was imported.
ok benno krw


# 1.308 06-Dec-2015 tedu

remove txpower option. only relevant to the now irrelevant wi driver.
(several other drivers misleadingly claim generic 802.11 txpower, but
do not in fact do anything. the knob is not connected to the radio.)
ok benno jsg krw reyk


# 1.307 25-Nov-2015 mpi

Put back 1.305 without breaking the hand rolled inet_net_pton(3) case
for IPv4.

Tested by sebastia@ and krw@


# 1.306 23-Nov-2015 mpi

Revert previous it introduces a regression found by krw@


# 1.305 23-Nov-2015 mpi

Initialize SIOCDIFADDR{_IN6,} argument as intended.

How this could have been unotified for so long? Thanks to sebastia@
for reporting a breakage when re-configuring an IPv6 static address.

ok sebastia@


# 1.304 24-Oct-2015 reyk

Add pair(4), a vether-based virtual Ethernet driver to interconnect
rdomains and bridges on the local system. This can be used to route
through local rdomains, to create L2 devices (like trunks) between
them, and many other things.

Discussed with many, with input from mpi@
OK sthen@ phessler@ yasuoka@ mikeb@


# 1.303 23-Oct-2015 dlg

tweak the vnetid so it can be optional and therefore cleared/deleted.

the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.

this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.

the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.

ok reyk@ who also simplified my diff


# 1.302 03-Oct-2015 florian

IPv6 transport for pflow data.
Input deraadt@
Bug fix & OK benno@


# 1.301 11-Sep-2015 stsp

In `ifconfig media` output, stop advertising media with fixed data
rates on wireless interfaces. They are not needed by mere mortals.
ok phessler miod kettenis deraadt mpi


# 1.300 11-Sep-2015 stsp

Fix ifconfig for ifmedia64.


Revision tags: OPENBSD_5_8_BASE
# 1.299 26-Jul-2015 chl

remove unused variable

ok mpi@ rzalamena@


# 1.298 22-Jul-2015 deraadt

process_mpw_commands should not go to install-media ifconfig


# 1.297 21-Jul-2015 rzalamena

Teach ifconfig(8) about mpw(4) commands.

ok claudio@, renato@, mpi@.


Revision tags: OPENBSD_5_7_BASE
# 1.296 05-Feb-2015 henning

implement "ifconfig <if> -inet", removing all inet addresses
for symmetry with -inet6 mostly. ok phessler theo


# 1.295 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.294 09-Jan-2015 sthen

Change rssi passed to ifconfig(8) to a signed value to fix printing signal
strengths on 802.11 interfaces. ok stsp@

Power on wireless interfaces is usually scaled in dBm. rssi (received signal
strength) is expected to be a -ve dBm values (i.e. [much] <1mW). Some (though
not all!) drivers store this as negative values, so it needs to be passed to
ifconfig that way for printing, not cast to an unsigned value. Valid range is
something like -40 to -90dBm, so the range available with a signed char is
reasonable whether it's stored as a +ve or -ve number.


# 1.293 06-Jan-2015 stsp

Remove the NOINET6 interface flag, a left-over from the times when IPv6
was enabled by default. Add AFATTACH/AFDETACH ioctls which enable/disable
an address family for an interface (currently used for IPv6 only).

New kernel needs new ifconfig for IPv6 configuration (address assignment
still works with old ifconfig making this easy to cross over).

Committing on behalf of henning@ who is currently lebensmittelvergiftet.
ok stsp, benno, mpi


# 1.292 04-Jan-2015 mpi

Sort wireless nodes by signal strength, from Simon Nicolussi.

ok stsp@, deraadt@


# 1.291 03-Jan-2015 jsg

move the list_cloners() prototype out of #ifndef SMALL
missed in rev 1.290


# 1.290 01-Jan-2015 krw

Enable 'ifconfig -C' (list dynamic interface types) on install
media. Use this feature in install scripts to eliminate manually
maintained list of dynamic interface types.

'-C' brought to my attention by reyk@, tweaks to install script to
use -C in get_ifdevs() from rpe@.

ok rpe@ deraadt@


# 1.289 14-Nov-2014 tedu

sort names for -C. ok reyk


# 1.288 14-Nov-2014 henning

move the trunk related functions out of ifdef SMALL, to allow trunk on
RAMDISKs. grows ifconfig on SMALL media slightly, verified to still fit on
amd64 i386 sparc64 alpha hppa macppc by me. ok krw reyk


Revision tags: OPENBSD_5_6_BASE
# 1.287 12-Jul-2014 henning

ewps, that giant table has -inet6 twice, for SMALL and !SMALL
no breakage involved, but wasn't correct in the SMALL case either


# 1.286 11-Jul-2014 henning

allow IFXF_AUTOCONF6 to be set and cleared.
"ifconfig <if> inet6 autoconf" to turn it on, -autoconf to turn it off.
show AUTOCONF6 in the flags line.
-inet6 turns IFXF_AUTOCONF6 off as well.
ok stsp benno florian bluhm


# 1.285 10-Jul-2014 stsp

Return RSN (WPA) information to userland during wireless scan, and
make ifconfig show whether a wireless network uses WEP or WPA.
Since struct ieee80211_nodereq grows in size old ifconfig won't be
able to scan when running on a new kernel.
While here, add missing ioctl constant IEEE80211_WPA_CIPHER_BIP.
ok jsg@


# 1.284 23-Jun-2014 henning

make "ifconfig <if> inet6 eui64" reset the NOINET6 flag
(unconditionally), so a link-local will be assigned if there isn't one
yet. ok krw benno todd sthen


# 1.283 12-May-2014 beck

Make ifconfig do something intelligent based on the required length of
WEP keys rather then being silently dumb, so when using WEP:
1) If the key is a plausible size try to use it.
2) If they key would be a plausible size with '0x' in front of it, add that.
3) If the key is not a plausible size, emit a warning and do not try to use it.
ok sthen@


# 1.282 05-Mar-2014 tedu

fix a null test, from remco.
and then modernize some other function pointer calls.


Revision tags: OPENBSD_5_5_BASE
# 1.281 21-Jan-2014 benno

allow pflow(4) to determine the src IP address based on the route
table if flowsrc is not set. Now works with new udp checksum code.
From Nathanael Rensen (nathanael.openbsd AT list DOT polymorpheus DOT
com), tweak and ok florian@


# 1.280 01-Dec-2013 stsp

Make ifconfig scan show the nwid, channel, and bssid for IBSS networks.
These were only shown for access points, so getting useful information
about IBSS networks in the area was somewhat difficult.
ok deraadt


# 1.279 22-Nov-2013 deraadt

Whole bunch of (unsigned char) casts carefully added for ctype calls.
Careful second audit by millert


# 1.278 21-Nov-2013 millert

Make the bit string unsigned char * in printb() and printb_status().
In practice we shouldn't have chars > 127 in these but it is better
not to assume this. OK deraadt@


# 1.277 12-Nov-2013 deraadt

add a variety of missing prototypes


# 1.276 05-Nov-2013 bluhm

Fix ifconfig with IPv6 tunnel addresses which was broken by the
vxlan(4) commit.
found by todd@; OK reyk@


# 1.275 28-Oct-2013 deraadt

use %d instead of %i in a few fprintf for clarity


# 1.274 17-Oct-2013 bluhm

The header file netinet/in_var.h included netinet6/in6_var.h. This
created a bunch of useless dependencies. Remove this implicit
inclusion and do an explicit #include <netinet6/in6_var.h> when it
is needed.
OK mpi@ henning@


# 1.273 13-Oct-2013 reyk

whitespace


# 1.272 13-Oct-2013 reyk

Import vxlan(4), the virtual extensible local area network tunnel
interface. VXLAN is a UDP-based tunnelling protocol for overlaying
virtualized layer 2 networks over layer 3 networks. The implementation
is based on draft-mahalingam-dutt-dcops-vxlan-04 and has been tested
with other implementations in the wild.

put it in deraadt@


# 1.271 09-Oct-2013 reyk

Change "physical address" to "tunnel:" in ifconfig's tunnel address
output. This is more consistent with the current ifconfig style and
matches the "tunnel" configuration command.

ok claudio@ jmc@ deraadt@


# 1.270 13-Sep-2013 florian

pflow(4) does not work without flowsrc set.
OK benno@


# 1.269 19-Aug-2013 dcoppa

Add missing util.h

ok otto@ mpi@ mikeb@


# 1.268 16-Aug-2013 mpi

Replace the misleading SIOC{G,S}IFGENERIC ioctls by SIOCG{G,S}PPPPARAMS.

This is another ABI break but no port rely on them as verified by naddy@.

ok claudio@, mikeb@, henning@


Revision tags: OPENBSD_5_4_BASE
# 1.267 16-Jul-2013 mpi

Make sure the ioctl(2) has been processed by sppp(4) before printing
any phase error.

This prevents ifconfig(8) from priting 'sppp: phase...' messages for
vlan(4) interfaces attached to interfaces with a long name. A better
fix should be cooked because various pseudo-interfaces still use the
same set of ioctl(2)s for different purposes.

Issue reported by jca@, ok claudio@, jca@


# 1.266 10-Jul-2013 mpi

Change the structure used in the SPPPIOSDEFS and SPPPIOGDEFS ioctls
to only include what is really needed. In particular stop including
a "struct ifnet" and move kernel-only definition into the proper #if
dance.

While here remove the unused spppinfo() from ifconfig.

ok guenther@, sthen@, mikeb@


# 1.265 02-Jul-2013 bluhm

Long passwords could not be replaced completely with shorter
passwords. ioctl(SIOCGVH) fills the carpr_key with the old value.
strlcpy() overwrites only the beginning of the key. Add a bzero()
to clear the rest.
Testing Jan Klemkow; OK florian@ mpf@


# 1.264 31-May-2013 yasuoka

Correct the range checks in ifconfig properly for vhid, advbase and advskew.
Clarify about the ranges in the man page.

ok mpf mcbride


# 1.263 25-Apr-2013 otto

fix format string; found while scaning the tree for time_t/ino_t problems;
ok deraadt@ krw@


# 1.262 19-Apr-2013 deraadt

remove comment about "make gcc happy" for variables which WERE being
used uninitialized... clean up time related variables too for 2038++
ok millert


# 1.261 03-Apr-2013 deraadt

handle larger time_t types; toss some unused code
ok guenther


Revision tags: OPENBSD_5_3_BASE
# 1.260 04-Dec-2012 deraadt

add group support back (for the ramdisk version)
spotted by rpe and sthen; ok krw


# 1.259 04-Dec-2012 deraadt

only needs sys/types.h not sys/param.h


# 1.258 23-Nov-2012 sthen

Display hardmtu value when "ifconfig hwfeatures" is used.
Looks fine reyk@ ok mikeb@


# 1.257 06-Sep-2012 tedu

move pkcs5_pbkdf5 function to libutil so everybody can play with it
ok deraadt jsing matthew


# 1.256 21-Aug-2012 bluhm

Reverse the name and meaning of the IFXF_INET6_PRIVACY interface
flag. It is now called IFXF_INET6_NOPRIVACY. So IPv6 privacy
addresses are on by default without resetting the flag during
ifconfig down/up.
OK stsp@, sperreault@ (who wrote the same diff)


Revision tags: OPENBSD_5_2_BASE
# 1.255 15-Apr-2012 jsg

fix a leak
ok krw@


Revision tags: OPENBSD_5_1_BASE
# 1.254 02-Feb-2012 benno

add netflow v9/ipfix support to pflow(4).
large parts written by Florian Obser (florian -at- narrans -dot- de).
feedback from sperreault@ gollo@ sthen@
ok from gollo@ dlg@ henning@


# 1.253 04-Dec-2011 haesbaert

Cleanup recently removed flags from ifconfig.c and its manpage.

ok jmc@ mikeb@


# 1.252 26-Nov-2011 haesbaert

Tie the 802.1p (CoS) value in vlan(4) with the new prio scheme in pf.

When transmitting through vlan(4), it will now use the prio value in
pf packet header. When receiving, we save the incoming Cos in the same
place, this gives us the hability to preserve the CoS value across two
different vlan interfaces.

This kills the SIOC[GS]VLANPRIO ioctls and removes the corresponding
buttons from ifconfig(8).

ok henning@ claudio@ mcbride@


# 1.251 02-Nov-2011 haesbaert

Expose if_capabilities to userland so that ifconfig can display the
device hardware features.
Tune ifconfig to show them with 'hwfeatures' argument.
While here, kill some old unused capabilities and respect 80 columns
in brconfig.h.

ok mcbride@, henning@, mpf@.


# 1.250 19-Sep-2011 henning

kill prototypes for long removed functions, Rafael Sadowski <rafael at
sizeofvoid.org>


# 1.249 21-Aug-2011 haesbaert

Remove old wpapsk entries. Cleanup casts and use timerclear.
ok mcbride


Revision tags: OPENBSD_5_0_BASE
# 1.248 09-Jul-2011 henning

rmove rotten netatalk bits


# 1.247 26-May-2011 sthen

Don't provide an af hint to getaddrinfo in settunnel(), this function
already checks that families of source and destination addresses match
and that's all we need.

This allows "ifconfig foo tunnel 1::1 2::2" syntax rather than requiring
"ifconfig foo inet6 tunnel 1::1 2::2", which in turn allows hostname.if
files to create an IPv4-in-IPv6 tunnel without games with shell escapes.

ok dcoppa@, seems ok todd@, "Yes, yes and yes" claudio@


# 1.246 23-Mar-2011 jsg

use the define for max rdomain with tunneldomain as well
ok claudio@


# 1.245 13-Mar-2011 stsp

Add a way to enable/disable Wake On LAN with ifconfig.
ok deraadt


Revision tags: OPENBSD_4_9_BASE
# 1.244 01-Mar-2011 claudio

Introduce a dummy function in the SMALL case to digest arguments like
"rdomain", "description", etc. so that the ifconfig on ramdisk is able
to parse hostname.if files on updates.
OK deraadt@


# 1.243 17-Feb-2011 camield

0-4095 inclusive is the correct (12 bit) vlan range

ok henning claudio miod


# 1.242 09-Nov-2010 jsg

when setting the rdomain, use the same define as the kernel
for the maximum route-id instead of a currently incorrect number
ok claudio@


# 1.241 01-Nov-2010 deraadt

add support for (full length only) hex keys to the wpakey code. for the
remainder of the 4.8->4.9 transition, alias wpapsk to wpakey (since
it swings both ways)
ok damien halex tedu


# 1.240 18-Oct-2010 deraadt

Add wpakey/-wpakey options. This was originally written by halex and
has gone many times around now (it is smaller now). man page diff
coming soon. Fits onto the media that need it.
ok halex


Revision tags: OPENBSD_4_8_BASE
# 1.239 03-Jul-2010 guenther

Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.

Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.

Written by claudio@, criticized^Wcritiqued by me


# 1.238 02-Jul-2010 deraadt

make lint a bit happier


# 1.237 26-Jun-2010 claudio

Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk


# 1.236 07-Jun-2010 claudio

Oups, an unused prototype sneaked into ifconfig. Found by jsg@


# 1.235 04-Jun-2010 claudio

Merge interface flags and xflags before printing them. So it is possible to
see if a interface is using the INET6_PRIVACY or is MPLS enabled.
If xflags uses more then 16 flags something else must be figured out.
OK stsp@ deraadt@


# 1.234 03-Jun-2010 stsp

Stop requiring the 'inet6' keyword when the 'autoconfprivacy' option is used.
Simplifies enabling autoconf privacy from hostname.if files. A line such as
'rtsol autoconfprivacy' will now work, as documented in ifconfig(8).
Pointed out by steven@.
ok deraadt@ steven@ todd@


# 1.233 28-May-2010 claudio

Add mpls/-mpls commands to enable MPLS label switching on an interface.


# 1.232 06-May-2010 claudio

Print the link state for devices not having if_media support by looking at
ifdata->ifi_link_state. Don't print in case of a unknown linkstate since
some devices (lo0) just have none.
OK sthen, dlg, blambert


# 1.231 06-Apr-2010 stsp

Simple implementation of RFC4941, "Privacy Extensions for Stateless
Address Autoconfiguration in IPv6". For those among us who are paranoid
about broadcasting their MAC address to the IPv6 internet.

Man page help from jmc, testing by weerd, arc4random API hints from djm.

ok deraadt, claudio


# 1.230 03-Apr-2010 deraadt

On the random MAC address also turn off the 'local administered' bit,
since it is our intent to deceive. Prompted by weerd.
ok ckuethe


# 1.229 02-Apr-2010 deraadt

randomized mac addresses, avaliable via 'ifconfig $if lladdr random'.
Note that not all device drivers do the work of the SIOCSIFLLADDR ioctl
correctly, but this is just more reason to get them fixed.
ok beck kettenis


Revision tags: OPENBSD_4_7_BASE
# 1.228 10-Jan-2010 guenther

s/setpriority/setifpriority/ to eliminate a conflict with setpriority()
To quote henning, 'ok gcc'


# 1.227 22-Dec-2009 deraadt

re-adding a group that exists is not an error
ok claudio


# 1.226 14-Dec-2009 deraadt

make ifconfig return with failure of bridge_rule; ok claudio


# 1.225 14-Dec-2009 deraadt

use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?


# 1.224 09-Dec-2009 deraadt

off by one in carp configuration; found by parfait, ok jsg


# 1.223 22-Nov-2009 claudio

Merge brconfig into ifconfig. It is annoying that it is impossible to do
ifconfig bridge0 add em0 add gif0 add vether0 up
instead you need to
ifconfig bridge0 create
brconfig bridge0 add em0 add gif0 add vether0 up
This is working for everything now but we may do some changes when needed.
Manpages and startup scripts are following soon.
OK deraadt@, henning@


# 1.222 22-Nov-2009 claudio

Fix ifconfig -a vs. ifconfig -A and make ifconfig without any arg behave
like ifconfig -a by setting the aflag to 1. Found with and OK deraadt@


# 1.221 21-Nov-2009 claudio

Add new option tunneldomain to ifconfig to specify the routing table
to be used for sending out gre/gif encoded packets. OK deraadt@, henning@


Revision tags: OPENBSD_4_6_BASE
# 1.220 19-Jun-2009 henning

after long discussion with many...
ifconfig <if> inet6 used to print all inet6 addresses, and last not least
the installer relies on that behaviour. so don't. to turn inet6 on again
you have to assign any inet6 address or run rtsol.
nobody happy about this asymmetry, but that is the best we could come up
with for now.


# 1.219 14-Jun-2009 dlg

enable support for deferring the packet that creates a state so that your
sync peers are able to get the states before the replies. previously there
was a race where the reply could hit a partner firewall before it had the
state for it, which caused the reply to get processed by the ruleset which
probably would drop it.

this behaviour is off by default because it does delay packets, which is
only wanted in active-active firewalls or when an upstream router is slow
to learn that you're moved the active member of the pfsync cluster. it also
uses memory keeping the packets in the kernel.

use "ifconfig pfsync0 defer" to enable it, "ifconfig pfsync0 -defer" to
disable.

tested by sthen@ who loves it. he's got manpage changes coming up for me.


# 1.218 11-Jun-2009 chl

remove unused variable

ok claudio@


# 1.217 05-Jun-2009 claudio

Make it possible to bind an interface to a rdomain. Manpage will follow soon.


# 1.216 04-Jun-2009 henning

allow IPvShit to be turned off completely per-interface.
ifconfig em0 -inet6
deletes all v6 addresses including link-local and prevents new ones from
being added.
ifconfig em0 inet6 <addr>
re-enables v6, brings the link local back and adds optional <addr>
ok theo reyk


# 1.215 27-Apr-2009 deraadt

let vlan functionality make it into the -DSMALL ifconfig binary
ok sthen


Revision tags: OPENBSD_4_5_BASE
# 1.214 16-Feb-2009 canacar

Allow username and password to be up to 255 characters in length.
Tested by many, thanks.
Put it in" deraadt@


# 1.213 15-Feb-2009 damien

make "ifconfig if0 chan" list the channels supported by the device.
add "ifconfig if0 scan" to scan for access points or to list known
stations in Host AP mode.
remove the [-]wmm command while i'm here. QoS is mandatory with
802.11n so there's not much point into making it an option.
fix parsing of the "powersave" command too.

discussed with deraadt@
man page hints from jmc@
display hints from sobrado@
"i like it" cnst@, grange@


# 1.212 13-Feb-2009 damien

Change ifconfig wpaakms default setting to `psk' instead of `psk,802.1x'.
Some supplicants will autoselect 802.1X without giving users the
possibility to choose between PSK or 802.1X.

Similarly, no longer announce `PSK with SHA-256 based KDF' AKMP (defined
in Draft 802.11w) by default in the RSN IE of beacons and probe responses
as it confuses some broken supplicants. This kind of sacrifies security
for interoperability with shitty (but unfortunately widespread) clients
that do not follow the 802.11 standard properly.
This fixes associations from Intel PROSet on XP and also reportedly fixes
some Mac OS clients. I will likely make `psk-sha256' configurable through
ifconfig wpaakms after the 4.5 release.


# 1.211 06-Feb-2009 grange

Remove bogus casts of integer constants SPPPIO[GS]DEFS to caddr_t
and fix typo while here.

ok canacar@


# 1.210 15-Dec-2008 fgsch

remove unused vars; damien@ ok.


# 1.209 12-Dec-2008 claudio

ifconfig(8) part to make it possible to set an interface priority.
OK deraadt@


# 1.208 24-Nov-2008 stevesk

remove trailing "\n" from errx()


# 1.207 17-Nov-2008 mpf

Fix printing of partner link aggregation group ID.
OK brad@


# 1.206 30-Sep-2008 deraadt

compress powersleep commands into one; ok damien


# 1.205 09-Sep-2008 reyk

fix printing by group name (eg. ifconfig em), do not abort in the
initial getinfo(), and remove a few superfluous warnings there.

ok deraadt@


# 1.204 09-Sep-2008 henning

welcome pflow(4), a netflow v5 compatible flow export interface.
flows export data gathered from pf states.
initial implementation by Joerg Goltermann <jg@osn.de>, guidance and many
changes by me. 'put it in' theo


# 1.203 07-Sep-2008 deraadt

Allow some set-style commands to have zero arguments. If there is an
argument after that command, check if it is a keyword, and if it is,
that means the original command really has no argument. Get it?
Now.. replace -m with media (no options), and -M with chan (no options).
Try 'ifconfig -a media chan' on a wireless & ethernet machine after this.
ok henning, reyk, thanks for the comments from others


Revision tags: OPENBSD_4_4_BASE
# 1.202 17-Jul-2008 sthen

Pasto in error message for setspppkey()
ok mbalmer@


# 1.201 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.200 15-Jun-2008 mpf

Add 802.3ad LACP support for trunk(4).
Implementation from NetBSD. Ported via FreeBSD's version in trunk^Wlagg(4).
This is still work in progress. Tested with a HP ProCurve 3500.
OK reyk@


# 1.199 14-Jun-2008 reyk

add carppeer; an option to specify a different multicast address or
even the unicast address of the remote carp peer. this especially
helps when the multicast carp advertisements are causing problems in
the network (some crappy switches don't do well with multicast), there
are conflicts with VRRP, or the policy of the network does not allow
multicast (most Internet eXchange points didn't allow carped OpenBGP
routers because of the multicast advertisements).

discussed with many
ok mpf@


# 1.198 13-Jun-2008 reyk

INADDR_PFSYNC_GROUP is defined as network byte order in the kernel but
as host byte order in userland. ifconfig didn't get this and always printed
the pfsync syncpeer on little endian machines because the check to prevent
printing the default address assumed the wrong byte order.

ok claudio@ rainer@


# 1.197 06-May-2008 pyr

bring in the mpe interface - for ``MPLS Provider Edge'' - this is a work
in progress and some bits need to be cleaned up but will be in-tree for
convenience.

ok claudio@, norby@


# 1.196 06-May-2008 markus

print IN6_IFF_AUTOCONF flag, too; ok henning some time ago


# 1.195 16-Apr-2008 damien

Kernel implementation of the 4-way handshake and group-key
handshake protocols (both supplicant and authenticator state
machines) as defined in the IEEE 802.11i standard.

Software implementation of the TKIP (Temporal Key Integrity
Protocol) and CCMP (CTR with CBC-MAC Protocol) protocols.

This diff doesn't implement any of the 802.1X authentication
protocols and thus only PSK authentication (using pre-shared
keys) is currently supported.

In concrete terms, this adds support for WPA-PSK and WPA2-PSK
protocols, both in station and hostap modes.

The following drivers are marked as WPA-capable and should
work: bwi(4), malo(4), ral(4), iwn(4), wpi(4), ural(4),
rum(4), upgt(4), and zyd(4)

The following options have been added to ifconfig(8):
wpa, wpapsk, wpaprotos, wpaakms, wpaciphers, wpagroupcipher

wpa-psk(8) can be used to generate keys from passphrases.

tested by many@
ok deraadt@


# 1.194 29-Mar-2008 damien

fix a free(NULL) in setcarp_nodes().

ok mpf@, chl@
"i agree with the diagnosis" oga@


Revision tags: OPENBSD_4_3_BASE
# 1.193 05-Feb-2008 mpf

Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be
configured with the new "carpnodes" and "balancing" options.
# ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50

Please note, that this is a flag day for anyone using carp balancing.
You'll need to adjust your configuration accordingly.

Addititionally this diff adds IPv6 NDP balancing support.

Tested and OK mcbride@, reyk@.
Manpage help by jmc@.


# 1.192 27-Nov-2007 chl

fix format strings

ok mpf@


# 1.191 27-Nov-2007 chl

fix format strings

ok mpf@ henning@


# 1.190 22-Nov-2007 mpf

Factor out the virtual host portion of carp into a separate struct
that is kept in a list per carp interface. This is the huge first
step necessary to make carp load balancing nice and easy. One carp
interface can now contain up to 32 virtual host instances.
This doesn't do anything useful yet, but here is how an ifconfig
for multiple entries now looks like:

# ifconfig carp2 carpnodes 5:0,6:100 192.168.5.88

carp2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr 00:00:5e:00:01:05
carp: carpdev sis0 advbase 1
state MASTER vhid 5 advskew 0
state BACKUP vhid 6 advskew 100
groups: carp
inet 192.168.5.88 netmask 0xffffff00 broadcast 192.168.5.255

OK mcbride@


# 1.189 31-Oct-2007 mikeb

Don't leak potentially secret authname through ioctl interface.

Suggestions from mpf@ and canacar@

ok deraadt mpf canacar


# 1.188 09-Oct-2007 joel

Fix range check for carp vhid: vhid 0 isn't valid


# 1.187 02-Sep-2007 deraadt

use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg


# 1.186 25-Aug-2007 henning

missing free, Igor Zinovik <zinovik@cs.karelia.ru>


Revision tags: OPENBSD_4_2_BASE
# 1.185 31-Jul-2007 pyr

When setting the vlandevice without specifying a tag, infer the tag
from the interface name, this allows constructs like:
ifconfig vlan15 vlandev smth0

ok reyk@, ``makes sense'' henning@


# 1.184 30-Jul-2007 pyr

strlen returns size_t.
ok henning, mbalmer.


# 1.183 30-Jul-2007 pyr

avoid segfault when empty string is passed as interface name.
ok henning@


# 1.182 19-Jun-2007 pyr

Allow IPv6 addresses to use the CIDR notation too, no need for separate
prefixlen specification when using this form.
man page bits by jmc.

ok henning@, ``looks sane'' djm@.


# 1.181 14-Jun-2007 reyk

Add a new "rtlabel" option to ifconfig. It allows to specify a route label
which will be used for new interface routes. For example,
ifconfig em0 10.1.1.0 255.255.255.0 rtlabel RING_1
will set the new interface address and attach the route label RING_1 to
the corresponding route.

manpage bits from jmc@
ok claudio@ henning@


# 1.180 13-Jun-2007 henning

allow IPv4 addresses to be specified in CIDR notation, no need for seperate
mask in that case. initially from rivo nurges <rix@estpak.ee>, but changed
quite a bit. this has annoyed me so long that I wonder why I hadn't fixed
that earlier... input & ok markus deraadt, manpage also jmc


# 1.179 05-Jun-2007 kurt

remove support for ipx. okay claudio@


# 1.178 26-May-2007 krw

When the SIOCGIFMEDIA ioctl fails, don't report a problem with
'SGIOCGIFMEDIA'.

Noticed by Stuart Henderson.


Revision tags: OPENBSD_4_1_BASE
# 1.177 15-Nov-2006 itojun

remove KAME_SCOPEID #ifdef.
__KAME__ should suffice (__KAME__ should be nuked too?)


# 1.176 10-Nov-2006 mk

Add -nwid command to allow wireless interfaces to not prefer a specific
access point. Does the same as nwid "" but since we have -nwkey for nwkey
etc. this is nice for consistency.

ok mbalmer reyk
man stuff also ok jmc


# 1.175 30-Sep-2006 ray

Don't use uninitialized variable.

From Peter Philipp <peter underscore philipp at freenet dot de>.

OK deraadt@.


Revision tags: OPENBSD_4_0_BASE
# 1.174 29-Aug-2006 henning

allow a numeric argument to "carpdemote" to in-/decrease the demotion
counter by more than one. manpage help by jmc, ok mcbride mpf deraadt


# 1.173 18-Aug-2006 deraadt

make non-root -M use not cut ifconfig output; ok jsg


# 1.172 02-Aug-2006 grunk

remove trailing blanks in output of ieee80211_status() as well.

help from claudio@, and ok claudio@ mickey@ mpf@


# 1.171 25-Jul-2006 grunk

ifconfig output contained trailing whites in inet and groups: lines
fix that by rearranging spaces in printf format strings

ok claudio@ mpf@ mickey@


# 1.170 27-Jun-2006 reyk

knf


# 1.169 27-Jun-2006 reyk

add the net80211 hostap options "nwflag hidenwid" for hidden SSID mode
and "nwflag nobridge" to prevent inter-station communications.
"hidenwid" will also work with wi(4) to replace the old -E 3 option of
wicontrol.

ok damien@ jmc@


# 1.168 23-Jun-2006 reyk

allow ifconfig to print the signal quality of the current ap. if the
driver reports a RSSI Max value, print the signal quality as a
percentage instead of the arbitrary "dB" value, this also applies to
the output of ifconfig -M (scan/node list).

ok damien@ jsg@


# 1.167 15-Jun-2006 deraadt

unused variable, spotted by pedro


# 1.166 14-Jun-2006 deraadt

unused var, wrong check for too many keys; mrd@alkemio.org


# 1.165 11-Jun-2006 jmc

simplify usage(); ok krw deraadt


# 1.164 03-Jun-2006 claudio

Do not set newaddr to 1 if "delete" was specified beforhands. In this case
doalias is < 0. This fixes the problem where ifconfig em0 delete 10.0.0.1
created a 0.0.0.0/0 route entry and created a total mess because of that.
Diff from markus@ OK beck@ markus@


# 1.163 02-Jun-2006 mpf

Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter
into the interface group. Thus we have the possibility
to define which carp interfaces are demoted together.

Put the demotion counter into the reserved field of the carp header.
With this, we can have carp act smarter if multiple errors occur.
It now always takes over other carp peers, that are advertising
with a higher demote count. As a side effect, we can also have
group failovers without the need of running in preempt mode.
The protocol change does not break compability with older
implementations.

Collaborative work with mcbride@

OK mcbride@, henning@


# 1.162 01-Jun-2006 claudio

Revert last commit. Modifing a interface does a remove and then an add.
We need to figure out a better way to fix this.
Brought up by markus@ OK beck@


# 1.161 01-Jun-2006 beck

ifconfig should be either deleting an interface address, or adding one in one
invocation, not both.

This change ensures that a delete does not also do an add.

Fixes stupid problem where deleting the last address with
ifconfig delete addr
worked differently than
ifconfig addr delete

where the first way would re-add an address of 0.0.0.0/0 after deleting
the address.

ok claudio@, krw@


# 1.160 17-May-2006 reyk

implement support for sppp(4) in ifconfig. have a look at the updated
manual pages pppoe(4) and sppp(4) for examples.

the spppcontrol(8) utility is not required anymore and will probably
be removed in the near future.

ok deraadt@


# 1.159 23-Mar-2006 mcbride

Print the lladdr on carp interfaces.

ok henning@


# 1.158 21-Mar-2006 claudio

Correctly check for the end of the cmds table. There is no need to check for
c_func2. Until now ifconfig accepted something like ifconfig tun0 1.2.3.4
1.2.3.5 foobar without error. Additionally change the error message to
a more comprehensible message. OK markus@, henning@


# 1.157 20-Mar-2006 dhill

Don't increment a pointer *before* testing it for NULL

ok deraadt@


Revision tags: OPENBSD_3_9_BASE
# 1.156 05-Jan-2006 norby

Make it possible to set a default vlan priority to a vlan interface.

ok claudio@ brad@


# 1.155 28-Nov-2005 markus

do not overflow ifr.ifr_addr; ok mpf, henning, hshoexer, deraadt


# 1.154 15-Nov-2005 jmc

add "-description" to usage();
ok henning@


# 1.153 14-Nov-2005 henning

add -descr / -description to clear the interface description, noticed todd


# 1.152 01-Nov-2005 deraadt

missing freeaddrinfo(); maticd@gmail.com


# 1.151 10-Oct-2005 henning

getifaddrs() slightly later in printif(), prevents possible memleak
Andrey Matveev <evol@online.ptt.ru>


# 1.150 03-Oct-2005 reyk

print all trunk flags

ok brad@


# 1.149 15-Sep-2005 pedro

Clean up compilation with -Wall, okay deraadt@
From: Leonardo Chiquitto Filho <leonardo@iken.com.br>


Revision tags: OPENBSD_3_8_BASE
# 1.148 10-Aug-2005 sturm

print session time in fixed width

ok henning, deraadt


# 1.147 24-Jun-2005 jolan

err -> errx


# 1.146 23-Jun-2005 mickey

iface description is not an array of ptr but rather just a string; jcs@ ok


# 1.145 12-Jun-2005 henning

let 'ifconfig <group>' work, displaying all the interfaces which are member
of the given group, markus ok


# 1.144 08-Jun-2005 henning

netns crap i missed earlier... damn unreliable tools


# 1.143 31-May-2005 jmc

tidy up the trunk stuff;


# 1.142 26-May-2005 henning

remove hiding of interface family groups


# 1.141 26-May-2005 frantzen

disallow interface group names that end in a digit to differentiate them from
true interfaces
ok henning@


# 1.140 25-May-2005 reyk

add ifconfig -M option to replace wicontrol -L and -l for ap scanning
and node listing. wicontrol is not supported by net80211 drivers
anymore. further improvements will be done.

ok dlg@, jsg@


# 1.139 24-May-2005 reyk

support trunk stacking (trunks as trunk ports) and some fixes

ok brad@


# 1.138 24-May-2005 reyk

initial import of a trunking (link aggregation and link failover)
implementation. it currently supports round robin mode with link state
checking, additional modes will be added later.

ok brad@, deraadt@


# 1.137 22-May-2005 henning

rewrite the interface groups printing code:
don't rely on the interface's driver-name based group to be the first in
the list
don't rely on one group == only default one
do not print the "all" group
don't segfault on interfaces with no group at all
ok mcbride


# 1.136 14-Apr-2005 henning

shave off a few bytes, alpha floppies fit again now


# 1.135 12-Apr-2005 markus

lladdr w/o colon; ok henning


# 1.134 11-Apr-2005 cloder

Handle getnameinfo failure. OK niallo


# 1.133 04-Apr-2005 deraadt

print lladdr instead of address; pointed out by a few


# 1.132 30-Mar-2005 tedu

add lladdr command to ifconfig to set MAC address. diffs from freebsd via
Kyunghwan KIM (prs 2117 and 2118) and Fredrik Widlund. ok deraadt


Revision tags: OPENBSD_3_7_BASE
# 1.131 15-Feb-2005 reyk

add txpower support to ifconfig

ok bob@ robert@ danh@ and others


# 1.130 20-Jan-2005 mcbride

Use syncdev instead of syncif in ifconfig, and modify ioctl struct pfsyncreq
in kernel code to match. Brings pfsync in line with carp, vlan and pppoe
devices. Old syncif and -syncif options still work, will be removed later.

ok markus@


# 1.129 18-Jan-2005 claudio

Print configured timeslot mask for PDH/TDM interfaces.
OK deraadt@


# 1.128 18-Jan-2005 claudio

Don't shift the timeslot map so that timeslot 1 ends in bit 0. E1 may need
to specify timeslot 0 and it is more intuitive.
From alex@ Ok deraadt@


# 1.127 29-Dec-2004 claudio

Put settimeslot() into #ifndef SMALL as it is not needed on ramdisks.
OK deraadt@


# 1.126 25-Dec-2004 deraadt

#ifndef SMALL throughout this, for install media; ok mcbride


# 1.125 07-Dec-2004 mcbride

Add the 'carpdev' option, to set the carp devices physical interface.
If not specified, the kernel will attempt to select the correct interface
by the subnet (this is the current behaviour).

ok deraadt@ henning@


# 1.124 07-Dec-2004 mcbride

KNF


# 1.123 07-Dec-2004 jmc

note that -a is the default if no params given;
`interface' is now optional;


# 1.122 07-Dec-2004 deraadt

default to interface printing, instead of help message. any illegal -
option goes to usage. initial work by ian, changed by me, ok mcbride


# 1.121 01-Dec-2004 jmc

add pppoe stuff to usage();
ok jaredy@


# 1.120 28-Nov-2004 canacar

In kernel pppoe client, a simple IPv4 only implementation.
Initial porting from NetBSD by David Berghoff.
Modified/simplified to match our sppp implementation.
ok deraadt@


# 1.119 17-Nov-2004 itojun

remove NI_WITHSCOPEID (which is not standard)


# 1.118 06-Nov-2004 reyk

added the "bssid" command to ifconfig, an extended ieee80211
status output and the missing man page entries for ifconfig.8
(from jared).

ok deraadt@, henning@


# 1.117 02-Nov-2004 henning

KNF - reyk, look at this diff
not that ifconfig is our prime example for nicely KNF'd and readable code tho


# 1.116 02-Nov-2004 deraadt

spacing


# 1.115 02-Nov-2004 reyk

added new commands to ifconfig used by net80211 interfaces:
mode (set mode for multi-mode interfaces) and chan (set the radio channel).
some additional output will be printed by "ifconfig -m".

ok deraadt@ millert@ damien@


# 1.114 11-Oct-2004 henning

ifgroups reqrite
there is now a TAILQ with all interface groups as members, and
in struct ofnet there is only a pointer to the group structure stored
and not its name.
mostly hacked at c2k4 and somewhere over the atlantic ocean
ok markus mcbride


# 1.113 15-Sep-2004 deraadt

ARGSUSED, remove unused, ...


Revision tags: OPENBSD_3_6_BASE
# 1.112 08-Aug-2004 deraadt

spacing


# 1.111 03-Aug-2004 mcbride

Allow a unicast ip address to be specified for pfsync with the 'syncpeer'
keyword. This address is used instead of the multicast address to send state
updates; this allows pairs of pfsync firewalls to protect the traffic
with IPSec.

ifconfig must be updated to match the kernel.


# 1.110 03-Jul-2004 deraadt

zap INET_ONLY, compress usage(); jared


# 1.109 03-Jul-2004 deraadt

ansi; jared


# 1.108 26-Jun-2004 markus

cleanup ioctl for ifgroups; ok pb@


# 1.107 26-Jun-2004 alex

Add option that allows to change timeslot range forn network card.
ok mcbride@


# 1.106 26-Jun-2004 pb

ignore IFGROUP errs in ifconfig -a for "too old" kernels right now


# 1.105 26-Jun-2004 pb

more netiso leftovers

by pointer from yared janovich

henning@ ok


# 1.104 26-Jun-2004 pb

groups in usage() - from jared yanovich


# 1.103 25-Jun-2004 pb

introduce "interface groups"

by "ifconfig fxp0 group foobar" "ifconfig xl0 group foobar"
these two interfaces are in one group.
Every interface has its if-family as default group.

idea/design from henning@, based on some work/disucssion from Joris Vink.

henning@, mcbride@ ok.


# 1.102 24-Jun-2004 henning

remove netiso stuff


# 1.101 21-Jun-2004 millert

Make printing of 802.11 fields consistent with the rest by printing
a colon (':') after the field name. Noticed by markus@, OK deraadt@


# 1.100 29-May-2004 jcs

introduce SIOCSIFDESCR and SIOCGIFDESCR to maintain interface
descriptions, configurable with ifconfig

help from various, ok deraadt@


# 1.99 18-May-2004 otto

Trailers are really wonders of the past. Remove them from man page and
usage. ok millert@


# 1.98 10-May-2004 deraadt

missing casts spotted by 64 bit cc


# 1.97 05-May-2004 deraadt

use strtonum all over the place; ok pb millert


# 1.96 27-Apr-2004 pb

clean up ifdef hell


# 1.95 27-Apr-2004 jmc

reworking of man page and sync/update usage();

this stuff is based mostly on diffs from jared yanovich, with some stuff
from myself and otto;

ok naddy@ otto@ markus@ deraadt@


# 1.94 27-Apr-2004 pb

missing ';' in actually unreached code (pointed out by logix(at)franken.de)


Revision tags: OPENBSD_3_5_BASE
# 1.93 18-Mar-2004 mcbride

Allow the state of a carp interface to be changed explicitly.

ok markus@


# 1.92 15-Mar-2004 deraadt

some small knf


# 1.91 08-Mar-2004 mcbride

Prevent user from specifying an interface name longer than IFNAMSIZ.

ok millert@


# 1.90 26-Feb-2004 millert

Deal correctly with printing interfaces with multiple trailing digits.
E.g. "ifconfig vlan1" should only match vlan1, not vlan1, vlan10, vlan11,
etc. OK tdeval@, hshoexer@, otto@. Closes PR 3693.


# 1.89 13-Jan-2004 mcbride

Allow ifconfig to print out all interfaces of a given type.
ie. 'ifconfig carp' prints out all carp interfaces.

ok hshoexer@ tdeval@


# 1.88 23-Dec-2003 markus

automagically create pseudo-network interfaces; ok deraadt@


# 1.87 15-Dec-2003 mcbride

Add initial support for pf state synchronization over the network.
Implemented as an in-kernel multicast IP protocol.

Turn it on like this:

# ifconfig pfsync0 up syncif fxp0

There is not yet any authentication on this protocol, so the syncif
must be on a trusted network. ie, a crossover cable between the two
firewalls.

NOTABLE CHANGES:
- A new index based on a unique (creatorid, stateid) tuple has been
added to the state tree.
- Updates now appear on the pfsync(4) interface; multiple updates may
be compressed into a single update.
- Applications which use bpf on pfsync(4) will need modification;
packets on pfsync no longer contains regular pf_state structs,
but pfsync_state structs which contain no pointers.

Much more to come.

ok deraadt@


# 1.86 08-Dec-2003 markus

add IOCIFGCLONERS; ifconfig -C; from netbsd; ok henning, deraadt


# 1.85 07-Dec-2003 markus

ANSI


# 1.84 03-Dec-2003 markus

add support for ifconfig clone; from netbsd; ok deraadt, henning


# 1.83 09-Nov-2003 mcbride

Unbreak printing of vlan interface information, commented out accidentally
in CARP import.


# 1.82 19-Oct-2003 mcbride

Remove commented out debug line committed by mistake.


# 1.81 17-Oct-2003 mcbride

Common Address Redundancy Protocol

Allows multiple hosts to share an IP address, providing high availability
and load balancing.

Based on code by mickey@, with additional help from markus@
and Marco_Pfatschbacher@genua.de

ok deraadt@


# 1.80 24-Sep-2003 deraadt

realloc fix


# 1.79 23-Sep-2003 deraadt

fix a few strlcpy


Revision tags: OPENBSD_3_4_BASE
# 1.78 30-Jul-2003 pvalchev

change SIOCDIFADDR/SIOCAIFADDR warnings into errors (now this has correct
return code in certain cases); ok henning itojun


# 1.77 26-Jun-2003 deraadt

bring protypes into scope. this requires some quirky handling, but in
the end everything is much clearer; ok tedu (itojun might like to see
how ifconfig looks after this)


# 1.76 11-Jun-2003 deraadt

ansification


# 1.75 02-Jun-2003 millert

Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999. Proofed by myself and Theo.


# 1.74 14-May-2003 itojun

move ETHERTYPE_xx declarations to <net/ethertypes.h>. meets netbsd practice.
deraadt ok


Revision tags: OPENBSD_3_3_BASE
# 1.73 16-Mar-2003 margarida

modifed -> modified


# 1.72 24-Nov-2002 henning

KNF


# 1.71 24-Nov-2002 henning

consistency: use sin6 as variable name for sockaddr_in6, not sin
no functional changes

ok millert@ pval@


# 1.70 23-Nov-2002 henning

typo (in #ifdef'd out code, but well...); Michal Ludvig <michal at logix.cz>


Revision tags: OPENBSD_3_2_BASE
# 1.69 08-Jul-2002 deraadt

make failed SIOCG80211NWKEY print alert more clearly; jolan@norm.encryptedemail.net


# 1.68 19-Jun-2002 millert

Since we can no longer count on isprint() to tell us whether or not
a character is 7-bit ASCII, check the high bit by hand when deciding
whether to print a WEP key as ASCII or hex.


# 1.67 14-Jun-2002 itojun

add "eui64" option. from ww@styx.org. sync usage with reality.


# 1.66 14-Jun-2002 itojun

metric and mtu are u_long, not int.


# 1.65 10-Jun-2002 markus

print ethernet address; ok provos@, itojun@


# 1.64 22-May-2002 deraadt

strcpy, sprintf death; mpech ok


# 1.63 26-Apr-2002 fgsch

use struct in_aliasreq instead of ifaliasreq when setting new inet
address. solves a sigbus error seen on sparc64 with new binutils.
from itojun@


# 1.62 25-Apr-2002 itojun

no need for __alignment__, it was paste error. from fgs/deraadt


Revision tags: OPENBSD_3_1_BASE
# 1.61 10-Apr-2002 millert

Add missing IFM_OPTIONS macro. Previously 'ifconfig -mediaopt' could
clear bits other than media options. Fix from NetBSD.


# 1.60 23-Feb-2002 millert

Add support for nwkey and powersave; from NetBSD


# 1.59 21-Feb-2002 millert

i_nwid is not a NUL-terminated string. Use the length parameter for the
length and sanity check against IEEE80211_NWID_LEN.


# 1.58 19-Feb-2002 mickey

when printing out the option list compare the option part only; fixes 802.11 mediaopt printing


# 1.57 17-Feb-2002 millert

Manual cleanup of remaining userland __P use (excluding packages maintained outside the tree)


# 1.56 16-Feb-2002 millert

Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.


# 1.55 13-Nov-2001 mickey

make setting ipx frame type work; from Ian McWilliam <ianm@cit.uws.edu.au>


# 1.54 05-Nov-2001 mpech

kill more registers;

millert@ ok


# 1.53 30-Oct-2001 millert

strncpy() -> strlcpy(); from Jean-Francois Brousseau


Revision tags: OPENBSD_3_0_BASE
# 1.52 19-Aug-2001 itojun

fix buffer underrun on 1.51


# 1.51 18-Aug-2001 deraadt

more careful with snprintf result code


# 1.50 25-Jul-2001 itojun

do not write into s6_addr[16] (out of bounds).


# 1.49 07-Jul-2001 deraadt

major -Wall cleanup, almost complete


# 1.48 07-May-2001 markus

tunneldelete -> deletetunnel


# 1.47 02-May-2001 itojun

implement "deletetunnel" (removes tunnel outer IP address pair)
rename "giftunnel" intto "tunnel", to reduce diffs with netbsd.
(giftunnel is still usable for backward compat)

markus and niels ok'ed.


Revision tags: OPENBSD_2_9_BASE
# 1.46 01-Mar-2001 itojun

on "giftunnel" configuration, use specified address family


# 1.45 20-Feb-2001 itojun

provide SIOC[SG]LIFPHYADDR, which greatly simplify userland manipulation.
sync with kame. old ioctls are kept but not really recommended.


# 1.44 18-Jan-2001 itojun

permit prefixlen against inet address, like:
# ifconfig fxp0 10.0.0.1 prefixlen 23


# 1.43 30-Dec-2000 angelos

Remove the dstsa/srcsa/clearsa directives, the bridge will be using
the gif interface instead.


# 1.42 18-Dec-2000 mickey

fix nwid get/set


# 1.41 10-Nov-2000 itojun

show pltime=0 address as "deprecated". sync with kame.


Revision tags: OPENBSD_2_8_BASE
# 1.40 03-Aug-2000 angelos

branches: 1.40.2;
Fix compilation in non-INET6 case (rfunk@funknet.net)


# 1.39 30-Jun-2000 itojun

correct address family handling in "giftunnel".
test with the following:
# ifconfig gif0 inet giftunnel localhost localhost
# ifconfig gif0 inet6 giftunnel localhost localhost


# 1.38 22-May-2000 itojun

correct gif physical address printing on non-IPv6 kernel.


# 1.37 15-May-2000 itojun

better scoped address handling on gif physical address printing.
(hide kame ifidx hack)


Revision tags: OPENBSD_2_7_BASE
# 1.36 28-Apr-2000 chris

Add vlan stuff to usage()


# 1.35 26-Apr-2000 chris

if_vlan support


# 1.34 14-Apr-2000 itojun

use getifaddrs, instead of SIOCGIFCONF.
XXX ifr/ifr6 manipulation is kind of ugly.


# 1.33 14-Apr-2000 itojun

recover "ifconfig -a" and "ifconfig -A" behavior for inet (least surprise).


# 1.32 11-Apr-2000 mickey

add 802.11's nwid command; add mtu command


# 1.31 18-Feb-2000 itojun

more alignment fix for SIOCGIFCONF.


# 1.30 18-Feb-2000 itojun

avoid alignment problem in 64bit arch.
netbsd 1.57 -> 1.58


# 1.29 18-Feb-2000 itojun

fix unaligned struct access on alpha.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>


# 1.28 15-Jan-2000 angelos

Add "giftunnel" keyword, obsoleting gifconfig(8).


# 1.27 09-Jan-2000 angelos

Use getaddrinfo() in srcsa/dstsa/clearsa.


# 1.26 27-Dec-1999 angelos

Handle srcsa/clearsa, and rename setsa to dstsa.


# 1.25 27-Dec-1999 angelos

Implement setsa keyword for enc interface TDB binding.


# 1.24 20-Dec-1999 itojun

remove temporary workaround for library dependency problem.
(this was just for kame repository)


# 1.23 08-Dec-1999 itojun

IPv6-enabled ifconfig from KAME.
it now loops through all the aliases on interfaces.
KAME_SCOPEID will be enabled when get{addr,name}info(3) are replaced with
KAME code.


Revision tags: OPENBSD_2_5_BASE OPENBSD_2_6_BASE
# 1.22 24-Feb-1999 deraadt

only allow src, dst address, not things like "ifconfig xx0 1 2 3 4 5 6"


# 1.21 24-Feb-1999 deraadt

for things like "ifconfig xx0 up", do not automatically set an address.


Revision tags: OPENBSD_2_4_BASE
# 1.20 03-Sep-1998 jason

Documentation for ifmedia & updated ifconfig usage


# 1.19 03-Sep-1998 jason

o OpenBSD gets if_media support (from NetBSD)
o rework/simplify if_xl to use it


# 1.18 09-Jul-1998 deraadt

indent


# 1.17 07-Jul-1998 deraadt

tiny freebsd cleanups


Revision tags: OPENBSD_2_3_BASE
# 1.16 20-Mar-1998 angelos

Add an explanatory comment, why we keep the interface address and keep
reseting it before each ioctl().


# 1.15 20-Mar-1998 angelos

Pay attention.


# 1.14 20-Mar-1998 angelos

Should work better for aliases now, with Theo's patch (soon to come).


# 1.13 17-Mar-1998 deraadt

finish atalk support; merged by I.McWilliam@st.nepean.uws.edu.au


# 1.12 31-Dec-1997 deraadt

address family; forget about this protocol family stuff for now


Revision tags: OPENBSD_2_2_BASE
# 1.11 20-Sep-1997 deraadt

fix extra "no such interface" messages


# 1.10 14-Sep-1997 deraadt

some -Wall


# 1.9 24-Aug-1997 deraadt

if interface not found by SIOCGIFCONF when printing, complain.


# 1.8 01-Jul-1997 deraadt

split -a into -a/-A


# 1.7 17-Jun-1997 deraadt

make 'ifconfig -a' and 'ifconfig de0' print full ifaliases output. this
was not fun, but the result sure is pretty. what is my reward?


Revision tags: OPENBSD_2_1_BASE
# 1.6 21-Jan-1997 deraadt

spacing glitch


Revision tags: OPENBSD_2_0_BASE
# 1.5 19-Sep-1996 deraadt

handle more interfaces in -a mode


# 1.4 16-Aug-1996 mickey

ipx.


# 1.3 23-Jun-1996 deraadt

update rcsid


# 1.2 06-Jan-1996 deraadt

from 4.4lite2; additional data from SIOCGIFCONF is at least sockaddr sized


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision